package j01gouzao;

public class J01 {
}

class Animal{
    private String name;

    public Animal(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
class Dog extends Animal{
    private int legs;

    public Dog(String name,int legs) {
        //super调用父类的构造方法
        super(name);
        //super是一个特殊的关键字，代表父类的引用，无法直接打印
        //System.out.println(super);
        //super调用父类构造，必须放在第一行
        this.legs = legs;

    }

    public int getLegs() {
        return legs;
    }

    public void setLegs(int legs) {
        this.legs = legs;
    }
}

class AnimalTest{
    public static void main(String[] args) {
//        Dog d1 = new Dog();
//        d1.setName("拉布拉多");
//        d1.setLegs(4);

        Dog d2 = new Dog("田园犬",4);
        System.out.println(d2.getName());
        System.out.println(d2.getLegs());
    }
}